/*
 * @Description: 类型转换测试类
 * @Author: rendc
 * @Date: 2025-07-17 09:10:56
 * @LastEditors: rendc

 * @LastEditTime: 2025-07-17 10:02:09
 */
public class Test01 {
  public static void main(String[] args) {
    // System.out.print("main");
    // 定义一个long类型的变量 用int赋值
    long num = 10;
    System.out.println("num:" + num);
    // 定义一个double类型的变量
    double price = 8.0F;
    System.out.println("price:" + price);
    long num1;
    int num2 = 10;
    num1 = num2;
    // 大转小 编译失败
    // float pi = 3.14;
    // int a = 3.0
    byte b = 10;
    short s = 5;
    // int num3 = b + s;
    // short num3 = b + s;
    // System.out.println("num3:" + num3);
    // 强制类型转换 显式类型转换
    double d1 = 3.14;
    float f1 = (float) 3.14;
    float f2 = 3.14F;
    System.out.println("d1:" + d1);
    System.out.println("f1:" + f1);
    System.out.println("f2:" + f2);
    // int 强转 注意是精度丢失 不是四舍五入
    int i = (int) 3.14;
    System.out.println("i:" + i);
    int i1 = (int) 3.54;
    System.out.println("i1:" + i1);
    byte b1 = 10;
    short s1 = 5;
    double d2 = 2.3;
    // (b1 - 5) * s1 + d2 结果是什么类型？
    double r = (b1 - 5) * s1 + d2;
    System.out.println("r:" + r); // 27.3
    float floatR = (float) ((b1 - 5) * s1 + d2);
    System.out.println("floatR:" + floatR); // 27.3
    // 特殊情况
    // int a = 10;
    byte byte1 = 10;
    System.out.println("byte1:" + byte1);
    byte byte2 = 127;
    System.out.println("byte2:" + byte2);
    // short short1 = 20;
    // System.out.println("short1:" + short1);
    // char char1 = 97;
    // System.out.println("char1:" + char1);
    byte btye2 = 10;
  }
}